import datetime
import time
from itertools import groupby
from operator import itemgetter

import math
from openerp import netsvc
from openerp import tools
from openerp.osv import fields, osv
from openerp.tools.translate import _


class hrm2_attendance_code(osv.osv):
    _name = "hrm2.attendance.code"
    _columns = {
        'name':fields.char('Name',size=64),
        'attendance_id': fields.integer('Attendance Code',required=True),  
        'device_id':fields.many2one('hr.device','Device Id',required=True)  
          
        }
    _defaults = {        
    }
    def name_get(self, cr, uid, ids, context=None):
        if isinstance(ids, (list, tuple)) and not len(ids):
            return []
        if isinstance(ids, (long, int)):
            ids = [ids]
        reads = self.read(cr, uid, ids, ['attendance_id'], context=context)
        res = []        
        for record in reads:
            name = str(_(record['attendance_id']))
            res.append((record['id'], name))
        return res
hrm2_attendance_code()
